﻿<?php
session_start();
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set('Asia/Shanghai');
//error_reporting(E_ALL^E_NOTICE);
//error_reporting(E_ALL ^ E_DEPRECATED);
error_reporting(0);

//文件路径及变量定义
define('STRING_DELIMITED','{I~N!T@E#R$V%A^L}');
define('ROOT_PATH', dirname(__FILE__));
define('JS_PATH','js/');
define('CSS_PATH','css/');
define('IMAGE_PATH','images/');
define('AJAX_PATH','ajax/');
define('COUNTRY_IMAGE','flags/');


require_once(ROOT_PATH."/conf/db.php");
require_once(ROOT_PATH."/class/db.class.php");
require_once(ROOT_PATH."/conf/function.php");


// 语言切换逻辑
if (isset($_GET['lang'])) {
	$_SESSION['lang'] = $_GET['lang'];
	header("Location: " . $_SERVER['PHP_SELF']);
	exit;
}

// 设置默认语言
$lang = isset($_SESSION['lang']) ? $_SESSION['lang'] : 'zh';
$lang_file = ROOT_PATH . "/lang/$lang.json";

// 加载语言文件
if (file_exists($lang_file)) {
	$translations = json_decode(file_get_contents($lang_file), true);
} else {
	$translations = json_decode(file_get_contents(ROOT_PATH . "/lang/zh.json"), true);
}

// 全局翻译函数
function t($key) {
	global $translations;
	return isset($translations[$key]) ? $translations[$key] : $key;
}

$db = new db();
$dbprefix = "";

$mt_id = ($_GET['mt_id'])?$_GET['mt_id']:4400;
if (is_numeric($mt_id)){
	$sql = "SELECT mt_cn_name,mt_en_name,mt_round,mt_round_num,mt_cr_id,mt_sts FROM `match` WHERE mt_id = '".$mt_id."' LIMIT 1";
	$res = $db->SelectSQL($sql);
	$num = count($res);
	if ($num>0){
		$match_cn_name =  '2024 BMW The Next ChampionShip';//$res[0]['mt_cn_name'];
		$match_en_name = '2024 BMW The Next ChampionShip';//$res[0]['mt_en_name'];
		$rd_id = (is_numeric($_GET['rd_id'])) ? $_GET['rd_id'] : $res[0]['mt_round'];
		$cr_id = $res[0]['mt_cr_id'];
		$maxRound   = $res[0]['mt_round_num'];
		$course = getCourse($cr_id);
		
		$mt_sts = $res[0]['mt_sts'];	
		$pars    = getPar($mt_id);                     //标准杆信息
		$players = matchPlayer($mt_id);                //参赛球员信息
		$mt_round =$res[0]['mt_round'];               //参赛球员信息
		$course_name ='上海PGA安赢高尔夫俱乐部';//$course[$cr_id];               //参赛球员信息
		
	} else { 
		echo '暂无比赛';
		exit;
	}
 
	if (empty($mt_id) || !is_numeric($mt_id)){
		echo "参数错误，无法获取信息！";
		exit;
	}
} else {
	echo '暂无比赛';
	exit;
}
?>